package com.manager.core.ad.single.csj;

import static yyee.llee.mmee.base_api_factory.ModuleConfig.AD_LOG_TAG;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import com.bykv.vk.openvk.TTAdLoadType;
import com.bykv.vk.openvk.TTRdVideoObject;
import com.bykv.vk.openvk.TTVfConstant;
import com.bykv.vk.openvk.TTVfNative;
import com.bykv.vk.openvk.TTVfSdk;
import com.bykv.vk.openvk.VfSlot;
import yyee.llee.mmee.ad_tj.ADTJ;
import yyee.llee.mmee.ad_tj.AdINfo;
import yyee.llee.mmee.base_api_net.base_api_bean.NATAdInfo;
import bi.GL;
import yyee.llee.mmee.common.global.Env;
import yyee.llee.mmee.pl190.host668.HandleUtils;
import yyee.llee.mmee.pl190.host668.StrongContext;
import com.manager.core.ad.AdsSdk;
import com.manager.core.ad.single.RewordListener;
import java.util.UUID;

public class CsjRewardVideoAd {

    private TTRdVideoObject mttRewardVideoAd;

    public void loadRewordVideo(Activity activity, RewordListener rewordListener) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdajpoureqofdjaiopuvz80 = new int[] { 1, 5 };
        for (int ireywq097904132784uafds = 1; ireywq097904132784uafds < arrfdajpoureqofdjaiopuvz80.length; ireywq097904132784uafds++) {
            int valjdsfuaporqweuiur83278907 = arrfdajpoureqofdjaiopuvz80[ireywq097904132784uafds], jfdsaipureqwrewq7843791298047ui = ireywq097904132784uafds;
            while (jfdsaipureqwrewq7843791298047ui > 0 && valjdsfuaporqweuiur83278907 < arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1]) {
                arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1];
                jfdsaipureqwrewq7843791298047ui--;
            }
            arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = valjdsfuaporqweuiur83278907;
        }
        AdsSdk.initMediationSDK(StrongContext.getApplication());
        GL.d(AD_LOG_TAG, "激励视频ID>>" + Env.FIRST_REWORD);
        TTVfNative mTTAdNative = TTVfSdk.getVfManager().createVfNative(activity);
        VfSlot adSlot = // 广告代码位Id
        new VfSlot.Builder().setCodeId(// 本次广告用途：TTAdLoadType.LOAD实时；TTAdLoadType.PRELOAD预请求
        Env.FIRST_REWORD).setAdLoadType(// 必填参数，期望视频的播放方向：TTAdConstant.HORIZONTAL 或 TTAdConstant.VERTICAL
        TTAdLoadType.LOAD).setOrientation(TTVfConstant.VERTICAL).build();
        mTTAdNative.loadRdVideoVr(adSlot, new TTVfNative.RdVideoVfListener() {

            // 请求广告失败
            @Override
            public void onError(int code, String message) {
                int passwordfdare32432qresafdsagda32 = 123456;
                int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
                int keydasopuerqnfdazcveq = 4;
                int lowupoeqfda7073fdal = 0;
                int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
                int middledaiueprnvznfewqip = 0;
                if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
                    int adfajpouqregjbdipug = 1;
                } else {
                    while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                        middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                        if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                            // 比关键字大则关键字在左区域
                            highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                        } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                            // 比关键字小则关键字在右区域
                            lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                        } else {
                        }
                    }
                }
                GL.d(AD_LOG_TAG, " 首页激励视频：Callback --> onError: " + code + ", " + message);
                if (rewordListener != null) {
                    rewordListener.end();
                }
            }

            @Override
            public void onRdVideoCached() {
                int passwordfdare32432qresafdsagda32 = 123456;
                int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
                int keydasopuerqnfdazcveq = 4;
                int lowupoeqfda7073fdal = 0;
                int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
                int middledaiueprnvznfewqip = 0;
                if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
                    int adfajpouqregjbdipug = 1;
                } else {
                    while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                        middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                        if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                            // 比关键字大则关键字在左区域
                            highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                        } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                            // 比关键字小则关键字在右区域
                            lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                        } else {
                        }
                    }
                }
                GL.d(AD_LOG_TAG, " 首页激励视频 Callback --> onRewardVideoCached");
                if (rewordListener != null) {
                    rewordListener.end();
                }
            }

            // 视频广告加载后，视频资源缓存到本地的回调，在此回调后，播放本地视频，流畅不阻塞。
            // 广告基础信息与素材缓存完成，此时调用广告展示流畅，是展示广告的最理想时机
            @Override
            public void onRdVideoCached(TTRdVideoObject ttRdVideoObject) {
                int passwordfdare32432qresafdsagda32 = 123456;
                int[] arrfdahiuryeqwfjdasopufdag = new int[] { 9, 4 };
                int lenfdajipureqopufdag = arrfdahiuryeqwfjdasopufdag.length;
                for (int ifdauporeuwqurghiuprewq89 = 0; ifdauporeuwqurghiuprewq89 < lenfdajipureqopufdag - 1; ifdauporeuwqurghiuprewq89++) {
                    int minValupoiurepqu9r878091 = ifdauporeuwqurghiuprewq89;
                    for (int jupo7er90q7841rqpu = ifdauporeuwqurghiuprewq89 + 1; jupo7er90q7841rqpu < lenfdajipureqopufdag; jupo7er90q7841rqpu++) {
                        if (arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] > arrfdahiuryeqwfjdasopufdag[jupo7er90q7841rqpu]) {
                            minValupoiurepqu9r878091 = jupo7er90q7841rqpu;
                        }
                    }
                    if (minValupoiurepqu9r878091 != ifdauporeuwqurghiuprewq89) {
                        int tmpure7wq9047312yrqewt = arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89];
                        arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89] = arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091];
                        arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] = tmpure7wq9047312yrqewt;
                    }
                }
                GL.d(AD_LOG_TAG, " 首页激励视频 Callback --> onRewardVideoCached");
                String uuid = UUID.randomUUID().toString();
                ADTJ.onAdFull(uuid, "reword", new AdINfo());
                HandleUtils.runUI(() -> {
                    /**
                     * 为保证广告视频播放的流畅建议在onRewardVideoCached回调加载完毕后，再在主线程中调用showRewardVideoAd方法进行广告的展示。 展示广告完毕之后及时把广告对象置为null
                     */
                    if (mttRewardVideoAd != null) {
                        // 展示广告，并传入广告展示的场景
                        mttRewardVideoAd.setRdVrInteractionListener(new TTRdVideoObject.RdVrInteractionListener() {

                            @Override
                            public void onShow() {
                                int passwordfdare32432qresafdsagda32 = 123456;
                                int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
                                int keydasopuerqnfdazcveq = 4;
                                int lowupoeqfda7073fdal = 0;
                                int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
                                int middledaiueprnvznfewqip = 0;
                                if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
                                    int adfajpouqregjbdipug = 1;
                                } else {
                                    while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                                        middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                                        if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                                            // 比关键字大则关键字在左区域
                                            highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                                        } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                                            // 比关键字小则关键字在右区域
                                            lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                                        } else {
                                        }
                                    }
                                }
                                Log.d(AD_LOG_TAG, " 首页激励视频 Show");
                                // FIRST_REWORD 新建的普通代码位
                                ADTJ.onAdShow(uuid, "reword", new NATAdInfo("", Env.FIRST_REWORD, "", 0));
                            }

                            @Override
                            public void onVideoBarClick() {
                                int passwordfdare32432qresafdsagda32 = 123456;
                                int[] arrfdajpoureqofdjaiopuvz80 = new int[] { 1, 5 };
                                for (int ireywq097904132784uafds = 1; ireywq097904132784uafds < arrfdajpoureqofdjaiopuvz80.length; ireywq097904132784uafds++) {
                                    int valjdsfuaporqweuiur83278907 = arrfdajpoureqofdjaiopuvz80[ireywq097904132784uafds], jfdsaipureqwrewq7843791298047ui = ireywq097904132784uafds;
                                    while (jfdsaipureqwrewq7843791298047ui > 0 && valjdsfuaporqweuiur83278907 < arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1]) {
                                        arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1];
                                        jfdsaipureqwrewq7843791298047ui--;
                                    }
                                    arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = valjdsfuaporqweuiur83278907;
                                }
                                // 广告点击
                                ADTJ.onAdClick(uuid, "reword", new NATAdInfo("", Env.FIRST_REWORD, "", 0));
                            }

                            @Override
                            public void onClose() {
                                int passwordfdare32432qresafdsagda32 = 123456;
                                int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
                                int keydasopuerqnfdazcveq = 4;
                                int lowupoeqfda7073fdal = 0;
                                int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
                                int middledaiueprnvznfewqip = 0;
                                if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
                                    int adfajpouqregjbdipug = 1;
                                } else {
                                    while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                                        middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                                        if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                                            // 比关键字大则关键字在左区域
                                            highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                                        } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                                            // 比关键字小则关键字在右区域
                                            lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                                        } else {
                                        }
                                    }
                                }
                                // 广告关闭
                                ADTJ.onAdClose(uuid, "reword", new NATAdInfo("", Env.FIRST_REWORD, "", 0));
                                if (rewordListener != null) {
                                    rewordListener.end();
                                }
                            }

                            @Override
                            public void onVideoComplete() {
                                int passwordfdare32432qresafdsagda32 = 123456;
                                int[] arrfdajpoureqofdjaiopuvz80 = new int[] { 1, 5 };
                                for (int ireywq097904132784uafds = 1; ireywq097904132784uafds < arrfdajpoureqofdjaiopuvz80.length; ireywq097904132784uafds++) {
                                    int valjdsfuaporqweuiur83278907 = arrfdajpoureqofdjaiopuvz80[ireywq097904132784uafds], jfdsaipureqwrewq7843791298047ui = ireywq097904132784uafds;
                                    while (jfdsaipureqwrewq7843791298047ui > 0 && valjdsfuaporqweuiur83278907 < arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1]) {
                                        arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1];
                                        jfdsaipureqwrewq7843791298047ui--;
                                    }
                                    arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = valjdsfuaporqweuiur83278907;
                                }
                                // 广告素材播放完成，例如视频未跳过，完整的播放了
                                if (rewordListener != null) {
                                    rewordListener.end();
                                }
                            }

                            @Override
                            public void onVideoError() {
                            }

                            @Override
                            public void onRdVerify(boolean b, int i, String s, int i1, String s1) {
                            }

                            @Override
                            public void onRewardArrived(boolean b, int i, Bundle bundle) {
                            }

                            @Override
                            public void onSkippedVideo() {
                                int passwordfdare32432qresafdsagda32 = 123456;
                                int[] arrfdajpoureqofdjaiopuvz80 = new int[] { 1, 5 };
                                for (int ireywq097904132784uafds = 1; ireywq097904132784uafds < arrfdajpoureqofdjaiopuvz80.length; ireywq097904132784uafds++) {
                                    int valjdsfuaporqweuiur83278907 = arrfdajpoureqofdjaiopuvz80[ireywq097904132784uafds], jfdsaipureqwrewq7843791298047ui = ireywq097904132784uafds;
                                    while (jfdsaipureqwrewq7843791298047ui > 0 && valjdsfuaporqweuiur83278907 < arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1]) {
                                        arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1];
                                        jfdsaipureqwrewq7843791298047ui--;
                                    }
                                    arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = valjdsfuaporqweuiur83278907;
                                }
                                // 用户在观看时点击了跳过
                                if (rewordListener != null) {
                                    rewordListener.end();
                                }
                            }
                        });
                        mttRewardVideoAd.showRdVideoVr(activity, TTVfConstant.RitScenes.CUSTOMIZE_SCENES, "scenes_reward");
                        mttRewardVideoAd = null;
                    } else {
                        GL.d(AD_LOG_TAG, "请先加载激励视频广告");
                    }
                });
            }

            // 广告基础信息加载完成，此方法是回调后是广告可调用展示的最早时机
            @Override
            public void onRdVideoVrLoad(TTRdVideoObject ttRdVideoObject) {
                int passwordfdare32432qresafdsagda32 = 123456;
                int[] arrfdajpoureqofdjaiopuvz80 = new int[] { 1, 5 };
                for (int ireywq097904132784uafds = 1; ireywq097904132784uafds < arrfdajpoureqofdjaiopuvz80.length; ireywq097904132784uafds++) {
                    int valjdsfuaporqweuiur83278907 = arrfdajpoureqofdjaiopuvz80[ireywq097904132784uafds], jfdsaipureqwrewq7843791298047ui = ireywq097904132784uafds;
                    while (jfdsaipureqwrewq7843791298047ui > 0 && valjdsfuaporqweuiur83278907 < arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1]) {
                        arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1];
                        jfdsaipureqwrewq7843791298047ui--;
                    }
                    arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = valjdsfuaporqweuiur83278907;
                }
                GL.d(AD_LOG_TAG, "Callback --> onRewardVideoAdLoad");
                // 开发者做一个标识
                mttRewardVideoAd = ttRdVideoObject;
            }
        });
    }
}
